﻿using System;
using System.Collections.Generic;
using System.Text;
using Xeml.Document;

namespace Xeml.Sampling
{
    public class ObPointAnnotationColumn : Column
    {
        private string _tag;
      
        //private Scope _scope;

        //private Level _level;

        //public Level Level
        //{
        //    get { return _level; }
        //    set { _level = value; }
        //}


        //public Scope Scope
        //{
        //    get { return _scope; }
        //    set { _scope = value; }
        //}


        //public TimeSpan Time
        //{
        //    get { return _time; }
        //    set { _time = value; SetNames(); }
        //}

        public string Tag
        {
            get { return _tag; }
            set { _tag = value; SetNames(); }
        }

        private void SetNames()
        {
            //StringBuilder sb = new StringBuilder();
            //sb.AppendFormat("{1}@{0}", _time, _tag);
            base.Name = _tag;
            base.DisplayName = _tag;
            base.NodeDisplayName = _tag;
           // base.DisplayName = sb.ToString();
           // sb = new StringBuilder();
            //switch (_level)
            //{
            //    case Level.Time:
            //        {
            //            base.NodeDisplayName = _time.ToString();
            //            break;
            //        }
            //    case Level.Tag:
            //        {
           //             base.NodeDisplayName = _tag;
            //            break;
            //        }
            //    default:
            //        break;
            //}
            
        }


        public override object ExtractRowValue(object extract)
        {
            ObservationPoint op = extract as ObservationPoint;
            string ret = "";
            if (op != null)
            {
                TaggedAnnotation ann = op.Annotations.Find(_tag);
                if (ann != null)
                {
                    ret = ann.Annotation;
                }
            }

            
            //if(sb != null)
            //{
            //    switch (Scope)
            //    {
            //        case Scope.Event:
            //            break;
            //        case Scope.ObservationPoint:
            //            {
            //                ObservationPoint op = sb.ObservationPoints.Find(_time);
                            
            //                break;
            //            }
            //        default:
            //            break;
            //    }
            //}
            return ret.Length == 0 ? "-" : ret;
               
        }
    }

   
}
